package com.zk.fm.component;

import android.content.Context;
import android.graphics.Color;
import android.util.AttributeSet;
import android.widget.TextView;

public class MyTextView extends TextView {

	public MyTextView(Context context, AttributeSet attrs) {
		super(context, attrs);
	}

	public MyTextView(Context context) {
		super(context);
	}

	@Override
	public void setText(CharSequence text, BufferType type) {
		String text_string = text.toString();
		int text_int = 0;
		try {
			text_int = Integer.parseInt(text_string);
		} catch (NumberFormatException e) {
			e.printStackTrace();
		}
		if (text_int > 15) {
			setTextColor(Color.RED);
		} else if (text_int > 10 && text_int <= 15) {
			setTextColor(Color.BLUE);
		} else if (text_int > 5 && text_int <= 10) {
			setTextColor(Color.GREEN);
		} else {
			setTextColor(Color.GRAY);
		}
		super.setText(text, type);
	}

}
